package com.company.笔试.出现1的次数;

import java.util.*;

import java.util.*;


public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param maxValue int整型 运算终点值
     * @return int整型
     */
    public static int res =0 ;

    public static void compute (int maxValue) {
        // write code here
        if (maxValue<=0) return;
        String oldStr = String.valueOf(maxValue);
        String newStr = oldStr.replaceAll("1","");
        res += oldStr.length() - newStr.length();
        compute(maxValue-1);
    }
    public int computeN (int maxValue) {
        for (int i = 1; i <= maxValue; i++) {
            String oldStr = String.valueOf(i);
            if (oldStr.contains("1")) {
                String newStr = oldStr.replaceAll("1","");
                res += oldStr.length() - newStr.length();
            }

        }
//        Solution.compute(maxValue);
        return Solution.res;
        // write code here
    }

    public static void main(String[] args) {
        String oldStr = String.valueOf(111111111);
        if (oldStr.contains("1")) {
            String newStr = oldStr.replaceAll("1","");
            res += oldStr.length() - newStr.length();
        }
//        System.out.println(new Solution().computeN(11111111));
        System.out.println(res);
    }
}

